$(function(){
	var a;
	var code;
	var random =  new Array(0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
	$.extend({
		runnum : function(){	
			code = "";
			for(i=0;i<4;i++){
				a = Math.floor(Math.random()*36);
				code += random[a];
				//console.log(code);
			}
			$('#vcodeimg').html(code);
			console.log($('#vcodeimg'))
		}
	})
	$.runnum();
	$('#vcodeimg').click(function(){
		$.runnum();
	})
	
	$('.txt_name').eq(0).keyup(function(){
		$a = this.value;
		$reg = /^1\d{10}$/;
		if($reg.test($a)){
			$('.ok1').css('display','block');
			return $a;
		}else{
			$('.ok1').css('display','none');
		}
	})
	$('.txt_name').eq(1).keyup(function(){
		
		$str = this.value.toUpperCase();
		if($str == $('#vcodeimg').html()){
			//alert()
			$('.ok2').css('display','block');
		}else{
			$('.ok2').css('display','none');
		}
	})
	$('.txt_name').eq(2).keyup(function(){
		$str = this.value;
		$reg = /^.{6,16}$/;
		if($reg.test($str)){
			//alert()
			$('.ok3').css('display','block');
			return $str;
		}else{
			$('.ok3').css('display','none');
		}
	})
	$('.txt_name').eq(3).keyup(function(){ 
		if(this.value == $str){
			$('.ok4').css('display','block');
		}else{
			$('.ok4').css('display','none');
		}
	})
	$('.actbtn').click(function(){
		$key = $('#phone').val();
		if($.cookie($a)){
			alert("此账号已注册");
		}else if($('.ok1,.ok2,.ok3,.ok4').css('display') == 'block' && $('#license:checked')){	
			window.location.href = 'index.html';
			$.cookie($a,$str,{expires:9999});
			$.cookie('userlogin',$key);
		}else{
			alert('输入有误');
		}
	})
})